/*     */ package com.jcrj.action;
/*     */ 
/*     */ import com.jcrj.entity.OUser;
/*     */ import com.jcrj.listener.UserInfo;
/*     */ import com.jcrj.listener.UserListener;
/*     */ import com.jcrj.service.UserService;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Vector;
/*     */ import javax.servlet.http.Cookie;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ 
/*     */ public class LoginAction extends BaseAction
/*     */ {
/*     */   private String name;
/*     */   private String password;
/*     */   private UserService userService;
/*     */   private Vector<OUser> userList;
/*     */   private Integer total;
/*     */ 
/*     */   public String login()
/*     */   {
/*  26 */     OUser user = this.userService.login(this.name, this.password);
/*  27 */     if (user != null) {
/*  28 */       List list = this.userService.findRoleByUser(user.getId().intValue());
/*  29 */       if ((list != null) && (!list.isEmpty())) {
/*  30 */         user.setOrgName(this.userService.getUserAllOrgName(user.getOrgId().intValue()));
/*  31 */         UserInfo info = UserInfo.getIntance();
/*  32 */         UserListener ul = new UserListener();
/*  33 */         ul.setUserInfo(user);
/*  34 */         info.addUser(ul.getUserInfo());
/*  35 */         super.getSession().put("user", ul);
/*  36 */         super.getSession().put("userInfo", user);
/*     */       } else {
/*  38 */         addFieldError("errorInfo", "该用户没有授权！");
/*  39 */         return "login";
/*     */       }
/*     */     } else {
/*  42 */       addFieldError("errorInfo", "用户名或密码错误");
/*  43 */       return "login";
/*     */     }
/*  45 */     Cookie cook = new Cookie("userCookie", this.name);
/*  46 */     cook.setMaxAge(864000);
/*  47 */     cook.setPath("/");
/*  48 */     super.getResponse().addCookie(cook);
/*  49 */     return "success";
/*     */   }
/*     */ 
/*     */   public String loginCert()
/*     */   {
/*  54 */     OUser user = this.userService.loginCert(this.name);
/*  55 */     if (user == null) {
/*  56 */       addFieldError("errorInfo", "用户不存在！");
/*  57 */       return "login";
/*     */     }
/*  59 */     user.setOrgName(this.userService.getUserAllOrgName(user.getOrgId().intValue()));
/*  60 */     UserInfo info = UserInfo.getIntance();
/*  61 */     UserListener ul = new UserListener();
/*  62 */     ul.setUserInfo(user);
/*  63 */     info.addUser(ul.getUserInfo());
/*  64 */     super.getSession().put("user", ul);
/*  65 */     super.getSession().put("userInfo", user);
/*  66 */     return "success";
/*     */   }
/*     */ 
/*     */   public String loginOut()
/*     */   {
/*  71 */     super.getSession().clear();
/*  72 */     return "success";
/*     */   }
/*     */ 
/*     */   public String loginClose() {
/*  76 */     super.getSession().clear();
/*  77 */     return null;
/*     */   }
/*     */ 
/*     */   public String totalUser() {
/*     */     try {
/*  82 */       UserInfo info = UserInfo.getIntance();
/*  83 */       Integer total = Integer.valueOf(info.getList().size());
/*  84 */       super.getResponse().getWriter().write(total.toString());
/*  85 */       super.getResponse().getWriter().flush();
/*     */     } catch (IOException e) {
/*  87 */       e.printStackTrace();
/*     */       try
/*     */       {
/*  90 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e1) {
/*  92 */         e1.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/*  90 */         super.getResponse().getWriter().close();
/*     */       } catch (IOException e) {
/*  92 */         e.printStackTrace();
/*     */       }
/*     */     }
/*  95 */     return null;
/*     */   }
/*     */   public String onlineUser() {
/*  98 */     UserInfo info = UserInfo.getIntance();
/*  99 */     this.total = Integer.valueOf(info.getList().size());
/* 100 */     this.userList = info.getList();
/* 101 */     return "success";
/*     */   }
/*     */ 
/*     */   public String getName() {
/* 105 */     return this.name;
/*     */   }
/*     */ 
/*     */   public void setName(String name) {
/* 109 */     this.name = name;
/*     */   }
/*     */ 
/*     */   public String getPassword() {
/* 113 */     return this.password;
/*     */   }
/*     */ 
/*     */   public void setPassword(String password) {
/* 117 */     this.password = password;
/*     */   }
/*     */ 
/*     */   public UserService getUserService() {
/* 121 */     return this.userService;
/*     */   }
/*     */ 
/*     */   public void setUserService(UserService userService) {
/* 125 */     this.userService = userService;
/*     */   }
/*     */ 
/*     */   public Vector<OUser> getUserList() {
/* 129 */     return this.userList;
/*     */   }
/*     */ 
/*     */   public void setUserList(Vector<OUser> userList)
/*     */   {
/* 134 */     this.userList = userList;
/*     */   }
/*     */ 
/*     */   public Integer getTotal()
/*     */   {
/* 139 */     return this.total;
/*     */   }
/*     */ 
/*     */   public void setTotal(Integer total) {
/* 143 */     this.total = total;
/*     */   }
/*     */ }

/* Location:           /Volumes/work/oa/WEB-INF/classes/
 * Qualified Name:     com.jcrj.action.LoginAction
 * JD-Core Version:    0.6.0
 */